/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sisgraf.model;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 *
 * @author Jordan de Carvalho Guerra
 */
@Entity
public class Acesso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    private Integer id;
    @ManyToMany(
        cascade = {CascadeType.PERSIST, CascadeType.MERGE},
        mappedBy = "acesso",
        targetEntity = Perfil.class)
    private Set<Perfil> perfil = new HashSet<Perfil>(0);
    @JoinColumn(name = "idModulo", referencedColumnName = "id",nullable = true)
    @ManyToOne(optional=true)
    private Modulo modulo;
    @JoinColumn(name = "idFuncao", referencedColumnName = "id",nullable = true)
    @ManyToOne(optional=true)
    private Funcao funcao;
    public Collection getPerfil() {
         return perfil;
     }
    public Acesso() {
        this.id=null;
        this.modulo=new Modulo();
        this.funcao=new Funcao();
    }
    public Acesso(Integer id) {
        this.id = id;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Modulo getModulo() {
        return this.modulo;
    }
    public void setModulo(Modulo modulo) {
        this.modulo = modulo;
    }
    public Funcao getFuncao() {
        return this.funcao;
    }
    public void setFuncao(Funcao funcao) {
        this.funcao = funcao;
    }
/*
    public Set<Perfil> getPerfil() {
        return perfil;
    }
 *
 */

    public void setPerfil(Set<Perfil> perfil) {
        this.perfil = perfil;
    }

}
